package com.example.gcmtest1.youtube;

import android.net.UrlQuerySanitizer;
import android.util.Log;

public class RealLink {

	private String logName = "RealLink";
	
	private String url;
	private String label;
	private UrlQuerySanitizer qq;
	
	private String contentType;
	private String quality;
	
	public RealLink(String url) {
		this.url = url;
		this.qq = new UrlQuerySanitizer(url);
		this.label = this.qq.getValue("type") + " " + this.qq.getValue("quality");
		
		try {
			this.contentType = this.qq.getValue("type").split(";")[0];
			this.quality = this.qq.getValue("quality").split(",")[0];
			this.label = contentType + " " + quality;
		} catch (Exception e) {
			Log.d(logName, e.toString());
		}
		
	}
	
	public void updateUrl(String newUrl) {
		this.url = newUrl;
	}
	
	
	public String getFileName(String fileName) {
		fileName = fileName + "-" + this.quality + "." + this.contentType.split("/")[1];
		return(fileName);
	}
	
	public String getLabel() {
		return(this.label);
	}
	
	public String getUrl() {
		return(this.url);
	}
}
